Move clip offsetting into _gdk_gc_intersect_clip_region
authorAlexander Larsson <alexl@redhat.com>
Thu, 4 Dec 2008 18:36:13 +0000 (19:36 +0100)
committerAlexander Larsson <alex@localhost.localdomain>
Thu, 2 Apr 2009 08:14:06 +0000 (10:14 +0200)
gdk/gdkgc.c
gdk/gdkinternals.h
gdk/gdkwindow.c

index 7b7e4eed5915645c9558985776e98011ce23423c..6bc3a994ce4d4453dc948220e427d3dae34e65e1 100644 (file)
@@ -564,17 +564,25 @@ _gdk_gc_set_clip_region_internal (GdkGC     *gc,
   _gdk_windowing_gc_set_clip_region (gc, region, reset_origin);
 }
 
-/* Takes ownership of passed in region, returns old clip region */
+/* returns old clip region */
 void
 _gdk_gc_intersect_clip_region (GdkGC     *gc,
                               GdkRegion *region,
+                              int        offset_x,
+                              int        offset_y,
                               GdkRegion **old_clip_region)
 {
   GdkGCPrivate *priv = GDK_GC_GET_PRIVATE (gc);
   GdkRegion *old_clip;
+  gboolean free;
 
   old_clip = priv->clip_region;
 
+  region = gdk_region_copy (region);
+
+  if (offset_x != 0 || offset_y != 0)
+    gdk_region_offset (region, offset_x, offset_y);
+  
   priv->clip_region = region;
   if (old_clip)
     gdk_region_intersect (region, old_clip);
index 3a1c1c6ff030f1f2d8c5c0175a9869508080115e..995f3bf455cb6aae005ec991fc969396ffdf57fc 100644 (file)
@@ -295,6 +295,8 @@ guint32    _gdk_gc_get_fg_pixel    (GdkGC *gc);
 guint32    _gdk_gc_get_bg_pixel    (GdkGC *gc);
 void      _gdk_gc_intersect_clip_region     (GdkGC     *gc,
                                             GdkRegion *region,
+                                            int        offset_x,
+                                            int        offset_y,
                                             GdkRegion **old_region);
 void       _gdk_gc_set_clip_region_internal (GdkGC     *gc,
                                             GdkRegion *region,
index 59cd8f4ef8bf15d04c863392e6a5044825c7c450..5d9b812a8075974d64b9c11ad718143f9619a420 100644 (file)
@@ -1983,6 +1983,7 @@ gdk_window_begin_paint_region (GdkWindow       *window,
                                     clip_box.x, clip_box.y,
                                     clip_box.width, clip_box.height);
     }
+
 #endif /* USE_BACKING_STORE */
 }
 
@@ -2270,16 +2271,15 @@ setup_clip_for_draw (GdkDrawable *drawable,
   GdkRegion *clip;
 
   if (_gdk_gc_get_subwindow (gc) == GDK_CLIP_BY_CHILDREN)
-    clip = gdk_region_copy (private->clip_region_with_children);
+    clip = private->clip_region_with_children;
   else
-    clip = gdk_region_copy (private->clip_region);
+    clip = private->clip_region;
     
-  /* There was a clip origin set appart from the window offset,
-     need to take this into consideration */
-  if (old_clip_x != 0 || old_clip_y != 0)
-    gdk_region_offset (clip, -old_clip_x, -old_clip_y);
-
-  _gdk_gc_intersect_clip_region (gc, clip, old_clip_region);
+  _gdk_gc_intersect_clip_region (gc, clip,
+                                /* If there was a clip origin set appart from the
+                                 * window offset, need to take that into consideration */
+                                -old_clip_x, -old_clip_y,
+                                old_clip_region);
 }
 
 static void
@@ -2289,16 +2289,13 @@ setup_clip_for_paint (GdkDrawable *drawable,
                      int old_clip_x, int old_clip_y,
                      GdkRegion **old_clip_region)
 {
-  GdkRegion *clip;
-
-  clip = gdk_region_copy (paint->region);
-  
-  /* There was a clip origin set appart from the window offset,
-     need to take this into consideration */
-  if (old_clip_x != 0 || old_clip_y != 0)
-    gdk_region_offset (clip, -old_clip_x, -old_clip_y);
-
-  _gdk_gc_intersect_clip_region (gc, clip, old_clip_region);
+  _gdk_gc_intersect_clip_region (gc,
+                                /* This includes the window clip */
+                                paint->region,
+                                /* If there was a clip origin set appart from the
+                                 * window offset, need to take that into consideration */
+                                -old_clip_x, -old_clip_y,
+                                old_clip_region);
 }